//窗口打开出发事件
// window.onload = function(){}



//创建对象
var $ = function () {
    return new Base();
}


// 创建一个基础的库
function Base() {
    //创建一个数组，用来保存获取的节点
    this.elements = [];


}

//根据id获取节点
Base.prototype.getID = function (id) {
    this.elements.push(document.getElementById(id));
    return this;
}

//根据标签的名字获取节点
Base.prototype.getTagName = function (tag) {
    var tags = document.getElementsByTagName(tag);
    for (var i = 0; i < tags.length; i++) {
        //将每个节点存入数组
        this.elements.push(tags[i]);

    }
    return this;
}


//设置CSS
Base.prototype.css = function (key, value) {
    //遍历
    for (var i = 0; i < this.elements.length; i++) {
        this.elements[i].style[key] = value;
    }
    return this;
}


//设置点击事件
Base.prototype.click = function (fn) {
    for (var i = 0; i < this.elements.length; i++) {
        this.elements.onclick = fn;
    }
    return this;
}








